package com.izkml.mlyun.hotreload.websocket.message;

import com.izkml.mlyun.hotreload.debug.protocol.ResultVo;
import com.izkml.mlyun.hotreload.enums.BusinessTypeEnums;
import lombok.Data;

/**
 *  发送消息
 *
 * @author zhangp
 * @version 1.0
 * @date 2025/5/15 0015 16:33
 */
@Data
public class SendMessage {

    private String jsonrpc = "2.0";

    private BusinessTypeEnums businessType;

    private ResultVo result;

    private Error error;

    private String id;

    public SendMessage() {

    }

    public SendMessage(ResultVo result) {
        this.result = result;
        this.businessType = result.getType().getBusinessType();
    }

    public SendMessage(String code, String message) {
        this.error  = new Error(code, message);
    }

    class Error {
        private String code;
        private String message;

        public Error(String code, String message) {
            this.code = code;
            this.message = message;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }
    }

}
